package location.prj;

import android.content.ContentValues;
import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.util.Log;

public class mydatabase extends SQLiteOpenHelper {
	
	
	private static final int DATABASE_VERSION = 1;
	 
    // Database Name
    private static final String DATABASE_NAME = "LocationData";
 
    // Contacts table name
    private static final String TABLE_LOCATION = "LocationTable";
 
    // Contacts Table Columns names
    private static final String KEY_ID = "ID";
    private static final String KEY_LAT = "LATITUDE";
    private static final String KEY_LONG = "LONGITUDE";
    private static final String KEY_ADDR = "ADDRESS";
 
   

	public mydatabase(Context context) {
		super(context, DATABASE_NAME, null, DATABASE_VERSION);
		// TODO Auto-generated constructor stub
	}

	@Override
	public void onCreate(SQLiteDatabase db) {
		// TODO Auto-generated method stub
		String CREATE_CONTACTS_TABLE = "CREATE TABLE " + TABLE_LOCATION + "("
                + KEY_ID + " INTEGER PRIMARY KEY," + KEY_LAT + " TEXT,"
                + KEY_LONG + " TEXT," + KEY_ADDR +" TEXT "+");";
        db.execSQL(CREATE_CONTACTS_TABLE);
        Log.d(DATABASE_NAME, "Created");
	}

	@Override
	public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
		// TODO Auto-generated method stub
		db.execSQL("DROP TABLE IF EXISTS " + TABLE_LOCATION);
		 
        // Create tables again
        onCreate(db);
		
	}
	
	public void datain(ContentValues c) {
		SQLiteDatabase db = this.getWritableDatabase();
		db.insert(TABLE_LOCATION, null, c);
		db.close();
	}
	
}
